
package com.xxx.yuedong.campaign.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxx.yuedong.campaign.db.dao.PlanDao;
import com.xxx.yuedong.campaign.pojo.Plan;
import com.xxx.yuedong.campaign.service.PlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author hc
 */
@Service
public class PlanServiceImpl implements PlanService {

    @Resource(name = "plan")
    private PlanDao planDao;

    @Override
    public int insert(Plan plan) {
        int rows = planDao.insert(plan);
        return rows;
    }

    @Override
    public HashMap searchPlanById(Long id) {
        HashMap map = planDao.searchPlanById(id);
        return map;
    }

    @Override
    public ArrayList<HashMap> searchPlanByGoal(HashMap param) {
        ArrayList<HashMap> list  = planDao.searchPlanByGoal(param);
        return list;
    }

    @Override
    public ArrayList<HashMap> searchAllPlan() {
        ArrayList<HashMap> list = planDao.searchAllPlan();
        return list;
    }

    @Override
    public PageInfo searchPlanList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Plan> list = planDao.searchPlanList();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public int deletePlanByIds(Integer[] ids) {
        int rows = planDao.deletePlanByIds(ids);
        return rows;
    }

    @Override
    public int updatePlanById(HashMap param) {
        int rows = planDao.updatePlanById(param);
        return rows;
    }
}
